<link rel="stylesheet" href="/stylesheets/style.css">
<div class="row">
    <div class="container-header">
        <p class="container-title">个人中心</p>
    </div>
    <div class="container-content">

        <div class="container-content-top">

        </div>
        <div class="container-content-center row">
            <div class="col-sm-2">
                <!--头像-->
                <div>
                    <img style="width: 80%;margin: 0 auto;border: 1px solid #b0b0b0;text-align: center" src="/images/avatar.png" alt="头像">
                </div>
                <% if (user.root || (user.role && (user.role.permissions.managerI || user.role.permissions.managerA) )) {%>
                <div>
                    <a href="/admin" type="button" class="btn btn-block btn-success" style="width: 80%;margin: 20px 0">苹安管理中心</a>
                </div>
                <% } %>
            </div>
            <div class="col-sm-10">
                <div class="form-group">
                    <label class="control-label">基本信息</label>
                </div>
                <div>
                    <div class="col-sm-6">
                        <div class="form-group">
                            <label class="control-label" for="username">用户名</label>
                            <input type="text" name="username" id="username" placeholder="加载中" value="<%= user.username%>" class="form-control" disabled>
                        </div>
                        <div class="form-group">
                            <label class="control-label" for="nickname">昵称</label>
                            <div class="input-group">
                                <!--<input type="text" class="form-control">-->
                                <input type="text" class="form-control" id="nickname" value="<%= user.nickname%>" placeholder="请输入昵称">
                                <span class="input-group-btn"><button id="update-btn" class="btn btn-success" type="button">修改</button></span>
                            </div>
                        </div>
                    </div>
                    <div class="col-sm-6">
                        <div class="form-group">
                            <label class="control-label" for="email">邮箱</label>
                            <div class="input-group">
                                <!--<input type="text" class="form-control">-->
                                <input type="text" class="form-control" id="email" placeholder="加载中" value="<%= user.email%>" disabled>
                                <span class="input-group-addon">@<%= website.email()%></span>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="control-label" for="role">角色</label>
                            <% if (user.role && user.role.name) { %>
                            <input type="text" name="role" id="role" class="form-control" value="<%= user.role.name%>" placeholder="加载中" disabled>
                            <% } else { %>
                            <input type="text" name="role" id="role" class="form-control" value="未知角色" placeholder="加载中" disabled>
                            <% }%>
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <label class="control-label"></label>
                </div>
                <div class="form-group">
                    <label class="control-label">iOS/Android权限</label>
                </div>
                <div>
                    <div class="form-group">
                        <div class="col-sm-3">
                            <div class="checkbox">
                                <label>
                                    <% if (user.role && user.role.permissions && user.role.permissions.packageI == true) { %>
                                    <input type="checkbox" checked  disabled>iOS打包权限
                                    <% } else { %>
                                    <input type="checkbox"  disabled>iOS打包权限
                                    <% }%>
                                </label>
                            </div>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-sm-3">
                            <div class="checkbox">
                                <label>
                                    <% if (user.role && user.role.permissions && user.role.permissions.packageA == true) { %>
                                    <input type="checkbox" checked  disabled>Android打包权限
                                    <% } else { %>
                                    <input type="checkbox"  disabled>Android打包权限
                                    <% }%>
                                </label>
                            </div>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-sm-3">
                            <div class="checkbox">
                                <label>
                                    <% if (user.role && user.role.permissions && user.role.permissions.managerI == true) { %>
                                    <input type="checkbox" checked  disabled>iOS管理权限
                                    <% } else { %>
                                    <input type="checkbox"  disabled>iOS管理权限
                                    <% }%>
                                </label>
                            </div>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-sm-3">
                            <div class="checkbox">
                                <label>
                                    <% if (user.role && user.role.permissions && user.role.permissions.managerA == true) { %>
                                    <input type="checkbox" checked  disabled>Android管理权限
                                    <% } else { %>
                                    <input type="checkbox"  disabled>Android管理权限
                                    <% }%>
                                </label>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <label class="control-label"></label>
                </div>
                <div class="form-group">
                    <label class="control-label">管理权限</label>
                </div>
                <!--<div>-->
                    <!--<div class="form-group">-->
                        <!--<div class="col-sm-3">-->
                            <!--<div class="checkbox">-->
                                <!--<label>-->
                                    <%  // if (user.role && user.role.permissions && user.role.permissions.checkUser == true) { %>
                                    <!--<input type="checkbox" checked  disabled>审核用户-->
                                    <% // } else { %>
                                    <!--<input type="checkbox" disabled>审核用户-->
                                    <% // }%>
                                <!--</label>-->
                            <!--</div>-->
                        <!--</div>-->
                    <!--</div>-->
                <!--</div>-->
                <div>
                    <div class="form-group">
                        <div class="col-sm-3">
                            <div class="checkbox">
                                <label>
                                    <% if (user.role && user.role.permissions && user.role.permissions.article == true) { %>
                                    <input type="checkbox" checked  disabled>管理文档
                                    <% } else { %>
                                    <input type="checkbox"  disabled>管理文档
                                    <% }%>
                                </label>
                            </div>
                        </div>
                    </div>
                </div>
                <div>
                    <div class="form-group">
                        <div class="col-sm-3">
                            <div class="checkbox">
                                <label>

                                </label>
                            </div>
                        </div>
                    </div>
                </div>
                <div>
                    <div class="form-group">
                        <div class="col-sm-3">
                            <div class="checkbox">
                                <label>

                                </label>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

        </div>
        <div class="container-content-bottom">

        </div>

    </div>
</div>
<script language="JavaScript">
    $("#update-btn").click(function () {
        var nickname = $("#nickname").val();
        nickname = nickname || '';
        if (nickname.length == 0) {
            showError('昵称不能为空');
            return;
        }
        $.post('/user/update',{nickname:nickname},function (data) {
            if (data.code == 0) {
                showSuccess('已更新昵称')
            } else  {
                showError(data.message);
            }
        })
    })
</script>